<?php
class Netflix_RentalHistoryItem {

	
	/**
	 * Rental History Item Id
	 *
	 * @var unknown_type
	 */
	public $id;
	
	/**
	 * Date watched.
	 *
	 * @var unknown_type
	 */
	public $watchedDate;
	
	/**
	 * Viewed Time.
	 *
	 * @var unknown_type
	 */
	public $viewedTime;
	
	/**
	 * Updated Date.
	 *
	 * @var unknown_type
	 */
	public $updatedDate;
	
	/**
	 * Type of Rental History.
	 * at home (shipped) , watched, returned
	 * 
	 * @var unknown_type
	 */
	public $type;
	
	/**
	 * Title
	 *
	 * @var unknown_type
	 */
	public $title;
	
	/**
	 * Title API Ref URL.
	 *
	 * @var unknown_type
	 */
	public $titleURL;
	
	public function __construct(){}
	
	/**
	 * Load data from XML.
	 * 
	 * @param SimpleXMLElement $simpleXMLObject
	 */
	public function loadXML($rentalHistoryItemXml){
		
		//Initialize and set variables.
		$this->id 			= (string)$rentalHistoryItemXml->id;
		$this->watchedDate 	= (string)$rentalHistoryItemXml->watched_date;
		$this->viewed_time 	= (string)$rentalHistoryItemXml->viewed_time;
		$this->updated     	= (string)$rentalHistoryItemXml->updated;
		$this->title		= (string)$rentalHistoryItemXml->title;
		
		//Set Type
		foreach($rentalHistoryItemXml->category as $category){
			
			$scheme = (string)$category['scheme'];
			$term   = (string)$category['term'];
			
			if(strpos($scheme, "rental_states")){
				$this->type = $term;
			}
			
		}
		
	}
	
}
?>